;递归计算过程
(define (f n)
  (cond ((< n 3) n)
        (else (+ (f (- n 1)) (* 2 (f (- n 2))) (* 3 (f (- n 3)))))))

;迭代计算过程
(define (f n)
  (define (sum a b c)
    (+ c (* 2 b) (* 3 a)))
  (define (f-iter a b c count)
    (cond ((= (+ count 1) n) (sum a b c))
          (else (f-iter b c (sum a b c) (+ count 1)))))
  (cond ((< n 3) n)
        (else (f-iter 0 1 2 2))))
